package com.ssm.controller;

import com.ssm.service.PoDaService;
import com.utils.Meg;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
public class PoDaController {
    @Autowired
    private PoDaService poDaService;

    @RequestMapping("/poDaView")
    public String poDaView(){
        return "poDa/poDa";
    }

    @ResponseBody
    @RequestMapping("/poDaData")
    public Meg poDaData(@Param("page") String page, @Param("limit") String limit){
        return Meg.success().add("data",poDaService.selectAll(limit,page));
    }




    @ResponseBody
    @RequestMapping("/getPoDa")
    public Meg getPoDaByPoPk(@RequestParam("poPk")Integer poPk){
        return Meg.success().add("data",poDaService.getDaByPoPk(poPk));
    }

    @ResponseBody
    @RequestMapping("/getPoDaList")
    public Meg getPoDaListByPoPkAndTime(@RequestParam("poPk")Integer poPk, @RequestParam("startTime") Date startTime, @RequestParam("endTime")Date endTime){
        return Meg.success().add("data",poDaService.getListByTimeAndPoPk(poPk,startTime,endTime));
    }

    @ResponseBody
    @RequestMapping("/getPoDaByPk")
    public Meg getPoDaByPk(@RequestParam("poDaPk")Integer poDaPk ){
        return Meg.success().add("data",poDaService.getPoDaByPk(poDaPk));
    }
}
